x86: Clean up do_iret() hypercall.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 3 Jul 2007 15:02:31 +0000 (16:02 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 3 Jul 2007 15:02:31 +0000 (16:02 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/x86_32/traps.c
xen/arch/x86/x86_64/compat/traps.c

index 4519348b8556ab9cda6c6d4e032bbb796d7c02ff..ebd174deb7166c9624424c598fcaf0aa3c629795 100644 (file)
@@ -179,12 +179,12 @@ unsigned long do_iret(void)
         goto exit_and_crash;
 
     /* Pop and restore EAX (clobbered by hypercall). */
-    if ( unlikely(__copy_from_user(&regs->eax, (void __user *)regs->esp, 4)) )
+    if ( unlikely(__copy_from_user(&regs->eax, (void *)regs->esp, 4)) )
         goto exit_and_crash;
     regs->esp += 4;
 
     /* Pop and restore CS and EIP. */
-    if ( unlikely(__copy_from_user(&regs->eip, (void __user *)regs->esp, 8)) )
+    if ( unlikely(__copy_from_user(&regs->eip, (void *)regs->esp, 8)) )
         goto exit_and_crash;
     regs->esp += 8;
 
@@ -192,7 +192,7 @@ unsigned long do_iret(void)
      * Pop, fix up and restore EFLAGS. We fix up in a local staging area
      * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
      */
-    if ( unlikely(__copy_from_user(&eflags, (void __user *)regs->esp, 4)) )
+    if ( unlikely(__copy_from_user(&eflags, (void *)regs->esp, 4)) )
         goto exit_and_crash;
     regs->esp += 4;
     regs->eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
@@ -200,7 +200,7 @@ unsigned long do_iret(void)
     if ( vm86_mode(regs) )
     {
         /* Return to VM86 mode: pop and restore ESP,SS,ES,DS,FS and GS. */
-        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 24) )
+        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 24) )
             goto exit_and_crash;
     }
     else if ( unlikely(ring_0(regs)) )
@@ -210,7 +210,7 @@ unsigned long do_iret(void)
     else if ( !ring_1(regs) )
     {
         /* Return to ring 2/3: pop and restore ESP and SS. */
-        if ( __copy_from_user(&regs->esp, (void __user *)regs->esp, 8) )
+        if ( __copy_from_user(&regs->esp, (void *)regs->esp, 8) )
             goto exit_and_crash;
     }
 
index f9a983d5d22653f81b4628b5196b9c494d5f9629..df1e512a21afa8eacefb30fbd8f29e45c097810f 100644 (file)
@@ -39,20 +39,23 @@ unsigned int compat_iret(void)
     struct cpu_user_regs *regs = guest_cpu_user_regs();
     u32 eflags;
 
+    /* Trim stack pointer to 32 bits. */
+    regs->rsp = (u32)regs->rsp;
+
     /* Restore EAX (clobbered by hypercall). */
-    if ( unlikely(__get_user(regs->_eax, (u32 __user *)regs->rsp)) )
+    if ( unlikely(__get_user(regs->_eax, (u32 *)regs->rsp)) )
         goto exit_and_crash;
 
     /* Restore CS and EIP. */
-    if ( unlikely(__get_user(regs->_eip, (u32 __user *)regs->rsp + 1)) ||
-        unlikely(__get_user(regs->cs, (u32 __user *)regs->rsp + 2)) )
+    if ( unlikely(__get_user(regs->_eip, (u32 *)regs->rsp + 1)) ||
+        unlikely(__get_user(regs->cs, (u32 *)regs->rsp + 2)) )
         goto exit_and_crash;
 
     /*
      * Fix up and restore EFLAGS. We fix up in a local staging area
      * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest.
      */
-    if ( unlikely(__get_user(eflags, (u32 __user *)regs->rsp + 3)) )
+    if ( unlikely(__get_user(eflags, (u32 *)regs->rsp + 3)) )
         goto exit_and_crash;
     regs->_eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF;
 
@@ -77,16 +80,16 @@ unsigned int compat_iret(void)
         {
             for (i = 1; i < 10; ++i)
             {
-                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
-                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
+                rc |= __get_user(x, (u32 *)regs->rsp + i);
+                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
             }
         }
         else if ( ksp > regs->_esp )
         {
             for (i = 9; i > 0; ++i)
             {
-                rc |= __get_user(x, (u32 __user *)regs->rsp + i);
-                rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i);
+                rc |= __get_user(x, (u32 *)regs->rsp + i);
+                rc |= __put_user(x, (u32 *)(unsigned long)ksp + i);
             }
         }
         if ( rc )
@@ -100,7 +103,7 @@ unsigned int compat_iret(void)
         regs->_eflags = eflags & ~(X86_EFLAGS_VM|X86_EFLAGS_RF|
                                    X86_EFLAGS_NT|X86_EFLAGS_TF);
 
-        if ( unlikely(__put_user(0, (u32 __user *)regs->rsp)) )
+        if ( unlikely(__put_user(0, (u32 *)regs->rsp)) )
             goto exit_and_crash;
         regs->_eip = ti->address;
         regs->cs = ti->cs;
@@ -110,8 +113,8 @@ unsigned int compat_iret(void)
     else if ( !ring_1(regs) )
     {
         /* Return to ring 2/3: restore ESP and SS. */
-        if ( __get_user(regs->ss, (u32 __user *)regs->rsp + 5)
-            || __get_user(regs->_esp, (u32 __user *)regs->rsp + 4))
+        if ( __get_user(regs->ss, (u32 *)regs->rsp + 5)
+            || __get_user(regs->_esp, (u32 *)regs->rsp + 4))
             goto exit_and_crash;
     }
     else